/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

/**
 *
 * @author zhouzhao
 */
public class photoPanel extends javax.swing.JPanel {

    public String imageName = "arb1.jpg";
    private BufferedImage image;
    private int width;
    private int height;
    /**
     * Creates new form photoPanel
     */
    public photoPanel() {
        initComponents();
        loadImage(imageName);
    }
    
    @Override
    public void paint(Graphics g){

        loadImage(imageName);
        g.clearRect(0, 0, 300, 300);
        g.drawImage(image, 0, 0, image.getHeight(), image.getWidth(), this);
    }
    
    public final void loadImage(String iName){
        try {
            image = ImageIO.read(new File(iName));
            
        } catch (Exception e) {
            System.out.println("error: " + e.toString());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
